Repository navigation
optimizer: measure n_edges scalers in memory-bounded chunks - #45
Merged
niklashoelter merged 1 commit intoOct 5, 2026
Merged
niklashoelter merged 1 commit into
niklashoelter merged 1 commit into
Conversation
torch-sim's autobatcher measures every system's neighbor-list edge count over the whole submitted state in one pass, which holds roughly ten kilobytes per atom and overflows a 44 GB card at a few million atoms. Route the measurement through chunks sized from the device's free memory so batch size is bounded by the optimization itself, not by this bookkeeping. Per-system numbers are identical either way.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
torch-sim's autobatchers compute the edge count for every system so they can bin-pack batches, and they do it in one neighbor-list pass over the whole state. That pass allocates fixed-width buffers (192 neighbor slots per atom), about 4.4 KiB per atom, so large jobs run out of GPU memory before the first optimization step. A cheetah acids run with all conformers kept (276k conformers, 10.7M atoms) needs about 45 GiB for this pass alone and fails on both a 24 GB card and an A40.
This PR splits that pass into chunks along system boundaries. Each chunk holds as many atoms as fit in half the device's free memory, and the per-system results are identical to the single pass. There is no new config option.
Changes
src/gpuma/autobatching.py(new):n_edges_scalers_chunked, which replaces torch-sim's_n_edges_scalerswhile_optimize_batchruns. A system too large for one chunk runs alone. On CPU, or when the state fits in one chunk, the call goes straight to torch-sim's single pass.src/gpuma/optimizer.py: installs the chunked pass before the batcher is built.docs/config.md: one paragraph on the behavior.tests/optimization/test_autobatching.py: chunk boundaries, oversized systems, the CPU fallback, results equal to the single pass, and the routing through torch-sim.Testing
batch_naive_neighbor_listNotes for review
torch_sim.autobatching._n_edges_scalers), so a torch-sim upgrade could break it. Tested against torch-sim 0.6.2. The cleaner long-term fix is to chunk this pass inside torch-sim itself. This is something I will work on. However, I do need this fix so I thought this was faster to release.